# encoding: utf-8
# @author: luzhangdan
# @file: yml_load.py
# @time: 2021/10/19 15:01

import yaml
from common.logger import GetLogger
from common.setting import DIR_NAME

logger = GetLogger().get_logger()


def read_yaml(file_name):
    """
    加载yml文件中的数据
    :param file_name: yml文件名
    :return: yaml的json数据
    """
    try:
        # 拼接yml文件的路径
        file_path = DIR_NAME + "/config/" + file_name
        logger.info(f"yml文件的路径是：{file_path}")
        with open(file_path, "r", encoding="utf-8") as f:
            # 获取yml中的数据
            data = yaml.load(f, Loader=yaml.FullLoader)
            logger.info(f"yml文件返回的的数据是：{data}")
        return data
    except Exception as e:
        logger.info(f"加载yml文件数据异常，异常信息是：{e}")


if __name__ == '__main__':
    read_yaml("http.yml")
